package com.itheima.config;


import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

//TODO:配置SqlSessionFactory和MapperScannerConfigurer

public class MybatisConfig {
    @Bean
    public SqlSessionFactoryBean getsFactoryBean(DataSource ds){
        SqlSessionFactoryBean sFactoryBean =new SqlSessionFactoryBean();
        sFactoryBean.setTypeAliasesPackage("com.itheima.domain");
        sFactoryBean.setDataSource(ds);
        return sFactoryBean;
    }

    @Bean
    public MapperScannerConfigurer getmsf(){
        MapperScannerConfigurer msf=new MapperScannerConfigurer();
        msf.setBasePackage("com.itheima.mapper");
        return msf;
    }

}
